﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace Client
{
    public partial class SetServerIPAddress : Form
    {
        public event SetServerIPAddressEventHandler OnSetServerIPAddress = null;
        public SetServerIPAddress()
        {
            InitializeComponent();
        }

        private void btnSet_Click(object sender, EventArgs e)
        {
            Regex r = new Regex("\\d{1,3}([.]\\d{1,3}){3}");
            Match m = r.Match(this.tbxIPAddress.Text.Trim());
            if (m.Success)
            {
                if (this.OnSetServerIPAddress != null)
                {
                    this.OnSetServerIPAddress(this, new SetServerIPAddressEventArgs(this.tbxIPAddress.Text.Trim()));
                }
                this.lbMessage.Text = "Successful.";
                this.Close();
            }
            else
            {
                this.lbMessage.Text = "IP address incorrect format.";
            }
        }
    }
}
